package com.migu.contacts.main.my.setting;

import static com.migu.contacts.net.Service.API;

import android.util.Log;
import android.widget.TextView;

import com.frank.libandroid.BaseActivity;
import com.frank.libandroid.BaseAdapter;
import com.frank.libandroid.butterknife.BindAdapter;
import com.frank.libandroid.butterknife.OnClick;
import com.migu.contacts.R;
import com.migu.contacts.bean.HelpBean;
import com.migu.contacts.databinding.ActivityHelpBinding;
import com.migu.contacts.databinding.ItemHelpBinding;
import com.migu.contacts.net.ResultCallback;

import java.util.List;

public class HelpActivity extends BaseActivity<ActivityHelpBinding> {
    @Override
    protected void initData() {
        super.initData();
        API.commonDocumentHelp().enqueue(new ResultCallback<List<HelpBean>>() {
            @Override
            protected void onSuccess(List<HelpBean> o) {
                Log.d(TAG, "onSuccess() called with: o = [" + o + "]");
                adapter.setData(o);
            }
        });
    }

    @BindAdapter(R.id.recyclerView)
    BaseAdapter<ItemHelpBinding, HelpBean> adapter = new BaseAdapter<ItemHelpBinding, HelpBean>() {
        @OnClick(R.id.content)
        public void content(ItemHelpBinding binding) {
            TextView content = binding.content;
            content.setSelected(!content.isSelected());
            if (content.isSelected()) {
                content.setMaxLines(Integer.MAX_VALUE);
                content.setCompoundDrawablesWithIntrinsicBounds(null, null, getDrawable(R.drawable.up), null);
            } else {
                content.setCompoundDrawablesWithIntrinsicBounds(null, null, getDrawable(R.drawable.down), null);
                content.setMaxLines(1);
            }
        }
    };
}